<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/react.development.js"></script>
    <script src="../lib/react-dom.development.js"></script>
    <script src="../lib/babel.min.js"></script>
</head>
<div id="root">

</div>

<body>
    <script type="text/babel">
        /**
         * 事件函数的参数传递
         * 包裹箭头函数
         * <button onClick={() => click3(1, 3)}>包裹箭头函数</button>
         */
        function click3(a, b) {
            console.log('click3')
            console.log(a)
            console.log(b)
        }

        function outFn() {
            click3(1, 2)
        }

        function click(event,a,b){
            event.preventDefault()
            console.log(a)
            console.log(b)
            console.log("click")
        }

        const root = ReactDOM.createRoot(document.getElementById('root'));
        root.render((
            <div>
                <h3>事件函数的参数传递</h3>
                <p>
                    <button onClick={click3}>click3</button>
                </p>
                <p>
                    <button onClick={outFn}>传递参数</button>
                </p>
                <hr/>
                <h3>包裹匿名函数</h3>
                <button onClick={() => click3(1, 3)}>包裹箭头函数</button>
                <hr/>
                <h3>即传递参数,又传递事件对象</h3>
                <p><a href="http://www.baidu.com" onClick={event => click(event,10,20) }>baidu</a></p>
            </div>
        ));
    </script>
</body>
</html>